<%@ page language="java" import="java.util.*,com.lmpop.trade.ti_attach.*,com.lmpop.trade.uploadFile.*,com.lmpop.frame.util.*,java.io.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 
 
 <% 
	
		request.setCharacterEncoding("UTF-8");
		String attach_root_id = "",img_type="0",tabShow="0",class_attrs="",area_attrs="",cust_names="",file_type="1",old_attach_root_id="";
		int start = 0;
		if(request.getParameter("start") != null && !request.getParameter("start").equals(""))
		{
			start = Integer.parseInt(request.getParameter("start"));
		}
		if(request.getParameter("old_attach_root_id") != null && !request.getParameter("old_attach_root_id").equals(""))
		{
			old_attach_root_id = request.getParameter("old_attach_root_id");
		}
		if(request.getParameter("attach_root_id")!=null && !request.getParameter("attach_root_id").equals("")){
			attach_root_id = request.getParameter("attach_root_id");
		}
		if(request.getParameter("img_type")!=null && !request.getParameter("img_type").equals("")){
			img_type = request.getParameter("img_type");
		}
		if(request.getParameter("tabShow")!=null && !request.getParameter("tabShow").equals("")){
			tabShow = request.getParameter("tabShow");
		}
		
		if(request.getParameter("class_attrs")!=null && !request.getParameter("class_attrs").equals("")){
			class_attrs = request.getParameter("class_attrs");
		}
		if(request.getParameter("area_attrs")!=null && !request.getParameter("area_attrs").equals("")){
			area_attrs = request.getParameter("area_attrs");
		}
		if(request.getParameter("cust_names")!=null && !request.getParameter("cust_names").equals("")){
			cust_names = request.getParameter("cust_names");
		}

		Config conf = new Config();
		Ti_attachInfo attachInfo = new Ti_attachInfo();	
		Hashtable suoMap = new Hashtable();
	  suoMap.put("attach_root_id",attach_root_id);	
	  suoMap.put("file_type","0");
	  String imgpath = "",dis_img="",suo_attach_id="";	
	  List suoList = attachInfo.getAttachInfoByMap(suoMap);
		
		Hashtable dxMap = new Hashtable();
		dxMap.put("attach_root_id",attach_root_id);	
		dxMap.put("file_type","2");							   
		List aList = attachInfo.getAttachInfoByMap(dxMap);
		
		if (aList==null || aList.size()<=0) file_type = "2";
		if (suoList==null || suoList.size()<=0) file_type = "0";		
		 
	%>

<html>
<head>
<title>图片上传</title>
<link  href="/program/plugins/upload/uploadImg/css.css" rel="stylesheet"  type="text/css" />

 	<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/interface/Ts_areaInfo.js'></script>
	<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/interface/Ts_categoryInfo.js'></script> 
	<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/engine.js'></script>
	<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/util.js'></script>
<script type="text/javascript" src="/program/plugins/upload/uploadImg/upload.js"></script>
<script type="text/javascript" src="/js/jquery.js"></script>
<script type="text/javascript" src="/js/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
      
	  $(document).ready(function(){
	  //alert('<%=tabShow%>');
		  
		  $(".tab_content").hide();
		  <%
		  	if (tabShow.equals("0"))
		  	{
		  %>
		  $("ul.tabs li:first").addClass("active").show();
		  $(".tab_content:first").show();
		  $(".share").show();
		  <%
		  	}
		  else
		  	{
		  %>
		  $("ul.tabs li:last").addClass("active").show();
		  $(".tab_content:last").show();
		  $(".share").hide();
		  <%
		  	}
		  %>
		  $("ul.tabs li").click(function(){
				   $("ul.tabs li").removeClass("active");
				   $(this).addClass("active");
				   $(".tab_content").hide();	   
				  
				   var activeTab = $(this).find("a").attr("href");
				   if (activeTab == "#tab3") 
				   {
				   	$(".share").hide();
				   }
				   else
				   {
				   $(".share").show();
				   }
				   	
				   $(activeTab).fadeIn();
				   return false;
		  });
    
});
</script>
<script type="text/javascript">
$(document).ready(function() {
$("#divmodel").load('/program/plugins/upload/uploadImg/imagelist.jsp?start=<%=start%>&file_type=<%=file_type%>&attach_root_id=<%=attach_root_id%>&old_attach_root_id=<%=old_attach_root_id%>&img_type=<%=img_type%>&tabShow=2&class_attrs=<%=class_attrs%>&area_attrs=<%=area_attrs%>&cust_names=<%=cust_names%>');
});
</script> 

</head>

<body>
 <div class="top">
     <div class="sc"><a href="#"><img src="/program/plugins/upload/uploadImg/images/wz_03.jpg" /></a></div>
 </div>
<hr/>

	
	<div class="w990">
	
	<ul class="tabs">
 
	<li><a href="#tab1">上传缩略图</a></li>
 
 
 	<%if(img_type.equals("1")){ %>

	
	<li><a href="#tab2">上传商品展示图</a></li>
 
 
    <%} %>

 <li><a href="#tab3">从图片库选择</a></li>
</ul>
 

 <%if(suoList!=null && suoList.size()>0){ %>

     &nbsp;<input type="button" value="确认上传" onclick="closeNotTip()" class="butcss"/>
 
 <%} %>


<div class="tab_container">

<div id="tab1" class="tab_content">
  <div style="margin-top:10px;"></div> 
   <form name="uploadform" method="POST" action="/servlet/uploadImg" ENCTYPE="multipart/form-data">
			<table width="100%" border=0 cellpadding=2 cellspacing=2 align=left >
				<tr>
					<td width="15%" style="border:1px solid #D1DDED;" align="center">
						
						<%
						   String share="";
						   if(suoList!=null && suoList.size()>0)
						   {
						      Hashtable soMap = (Hashtable)suoList.get(0);
				          if(soMap.get("file_path")!=null) imgpath= soMap.get("file_path").toString();
							  	if(soMap.get("attach_id")!=null) suo_attach_id= soMap.get("attach_id").toString();
							  	if(soMap.get("rsrv_str1")!=null) share= soMap.get("rsrv_str1").toString();
						   }
						 					
               if(!imgpath.equals(""))
               {
									dis_img = "<img src="+imgpath+"  width=80 height=76 />";
						   }
						   else
						   	{
									dis_img = "<img src=/program/plugins/upload/uploadImg/images/cpwu.gif  width=80 height=76 />";	
						   }
							
								out.println("<div id=imgUploadDiv >"+dis_img+"</div>");
							
								if(!imgpath.equals(""))
								{
									if (!share.equals("1"))	out.println("<div id=delWordDiv ><a href='/doTradeReg.do?pkid="+suo_attach_id+"&bpm_id=5712&file_path="+imgpath+"&sharetag="+share+"' >删除</a> </div>");
									out.println("<div id=delWordDiv><a href='"+imgpath+"' target='_blank'>原图</a></div>");
								}
								
						%>
						
				  </td>

            <td style="font-size:12px;" valign="top">
              <% 
              	if(suoList==null || suoList.size()==0)
              	{
              %>					  
					  	<input name="minfile" id="minfile" size="40" type="file">
					  	<div style="margin-top:8px"></div>					  
					  	图片格式限制:&nbsp;<font color="#303A43"><%=conf.getString("imagesext")%>;</font><br/>
              图片大小限制:&nbsp;<font color="#303A43">宽：<%=conf.getString("saleimg_min_width")%>px，高：<%=conf.getString("saleimg_min_height")%>px</font>
					  	<div style="margin-top:8px"></div>
			        
			        <br>
						<input name="formSub" value="上 传"  type="button"  class="butcss"  onclick="uploudImg('0')"/>			
						<%
							}
						%>
					</td>
				</tr>
				 
			</table>
				<input type="hidden" name="attach_root_id" value="<%=attach_root_id%>" />
				<input type="hidden" name="class_attr1" id="class_attr1" value="" />
				<input type="hidden" name="area_attr1" id="area_attr1" value="" />
				<input type="hidden" name="cust_name1" id="cust_name1" value="">
		
		</form>
                    
</div>


<div id="tab2" class="tab_content">
      
 <div class="content">
     	
	 <% 
					

	  		 
				 String one_file_path="/program/plugins/upload/uploadImg/images/cpwu.gif",one_attach_id="";
				 if(aList!=null && aList.size()>0)
				 {
	  					Hashtable oneMap = (Hashtable)aList.get(0);
	  					if(oneMap.get("attach_id")!=null) one_attach_id = oneMap.get("attach_id").toString();
	  					if(oneMap.get("file_path")!=null) one_file_path = oneMap.get("file_path").toString();
						if(one_file_path.equals(""))
						{
						  one_file_path = "/program/plugins/upload/uploadImg/images/cpwu.gif";
						}
						
	  			}		
	  					
	  		%>	
	 
	 
	 
   
    <div class="left" style="width:270px;height:270px;">
	       <img src="<%=one_file_path%>" id="one_file_path" width="270" height="270" />
	</div>
	  
	  
	  
	  <div class="center" id=demo>
	  	
	  		<div id=demo1> 
            
		<% 
					
				 int listsize=0;
				 if(aList!=null && aList.size()>0){
	  				listsize = aList.size();
	  				Hashtable aMap = new Hashtable();
	  				for(int i=0;i<aList.size();i++)
	  				{
	  					aMap = (Hashtable)aList.get(i);
	  					String attach_id = "",file_path = "",attach_name="",imgshare="";
	  					if(aMap.get("attach_id")!=null) attach_id = aMap.get("attach_id").toString();
	  					if(aMap.get("file_path")!=null) file_path = aMap.get("file_path").toString();
							if(aMap.get("attach_name")!=null) attach_name = aMap.get("attach_name").toString();
							if(aMap.get("rsrv_str1")!=null) imgshare= aMap.get("rsrv_str1").toString();
							if(file_path.equals(""))
							{
							  file_path = "/program/plugins/upload/uploadImg/images/cpwu.gif";
							}
						
	  					
	  					
	  		%>
			 
	  		
	  		<img src="<%=file_path %>" onmouseout="levelImage(this)" onmouseover="showImage(this)" width="65" height="65"/>
	  		<%
	  			if (!imgshare.equals("1"))	
	  			{
	  		%>
	  		<a href="/doTradeReg.do?pkid=<%=attach_id%>&bpm_id=5712&file_path=<%=file_path%>&sharetag=<%=imgshare%>">删除</a>
	  		<%
	  			}
	  		%>
	  		<a href="<%=file_path%>">原图</a>
	  		<%
	  				}
	  			}
	  		%>
			</div> 
			 
		</div> 

	  <div class="right">
	  	 <form action="/servlet/uploadImg" enctype="multipart/form-data" method="post" name="goodsForm">	  	 	
	  	 	<input type="hidden" name="attach_root_id" value="<%=attach_root_id%>" />
	  	 	
		     <div class="right_t" id="uploadDiv">
			      
			    大图:<input type="file" name="bigfile1" id="bigfile1" size="25">
				  <div style="margin-top:8px"></div>                                                           
				  图片格式限制:&nbsp;<font color="#303A43"><%=conf.getString("imagesext")%>;</font>
				  <div style="margin-top:8px"></div>
				  <img src="/program/images/bullet_error.png" border=0 />请您上传相应大小图片，否则将影响前台的展示！
			   	<div style="margin-top:8px"></div>
				  大图大小限制:&nbsp;<font color="#303A43">宽<%=conf.getString("saleimg_big_width")%>px，高<%=conf.getString("img_big_height")%>px;</font>			   		
			    <div style="margin-top:8px"></div>			     
				  <input name="formSub" value="上 传"  type="button"  class="butcss"  onclick="uploudImg('1')"/>		  				  
				  <input type="hidden" value="1"  name="upload_num" id="upload_num" />
          <input type="hidden" name ="tabShow" value="1">			  
			   </div>			   
			   <div class="right_d"> 
				   <div class="rightDspan"></div>
				   <br/>				   	
			   </div> 
			   <input type="hidden" value="<%=conf.getString("imagesext")%>"  name="imagesext" id="imagesext" />
				<input type="hidden" name="class_attr2" id="class_attr2" value="" />
				<input type="hidden" name="area_attr2" id="area_attr2" value="" />
				<input type="hidden" name="cust_name2" id="cust_name2" value="">
		  	</form>
	  </div>
   </div>

   
</div>
<div style="clear:both;">&nbsp;</div>
<div class="share"> 
<table style="font-size:12px;border:1px solid #D1DDED;color:blue;width:100%;float:left" valign="top">
	 <tr>
		<td colspan="2">
			<input type="checkbox" id="share" name="share">共享此图片											
		</td>
	<tr>
		<td>									 
			所属分类		
		</td>
		<td>					 
			<select  style="float:left;margin-right:6px;" name="sort1" id="sort1" onChange="setSecondClass(this.value);" onclick="setTypeName1(this)" >
				<option value="">请选择</option>
			</select>			
			<select style="float:left;margin-right:6px;" name="sort2" id="sort2" onChange="setTherdClass(this.value);" onclick="setTypeName2(this)">		
				<option value="">请选择</option>
			</select>		
			<select name="sort3" id="sort3" style="float:left;margin-right:6px;" onclick="setTypeName3(this)">
				<option value="">请选择</option>
			</select>
			&nbsp;&nbsp;
			<input type="hidden" name="cat_attr" id="cat_attr" value=""/>
			<input type="hidden" name="class_attr" id="class_attr" value="" />
			<input type="hidden" name="area_attr" id="area_attr" value="" />
			<input type="hidden" name="class_attr_bak" id="class_attr_bak" value="" />
			<input type="hidden" name="class_id1" id="class_id1" value="" />									  
			<input type="hidden" name="class_id2" id="class_id2" value="" />
			<input type="hidden" name="class_id3" id="class_id3" value="" />
		</td>
	</tr>							
	<tr>
		<td>
			 产地
		</td>
		<td>
			<select name="province" id="province" onclick="setCitys(this.value)">
			  <option value="">省份</option> 
			</select>
			<select name="eparchy_code" id="eparchy_code" onclick="setAreas(this.value)">
			  <option value="">地级市</option> 
			 </select>
			<select name="city_code" id="city_code" style="display:inline" >
			 <option value="">市、县级市、县</option> 
			</select>
		  <input type="hidden" name="area_attr_bak" id="area_attr_bak" value="" />
		 
		</td>
	</tr>	
	<tr>								
		<td>
			源企名称
		</td>
		<td>
			 <input name="cust_name" id="cust_name" size="40" type="text">
		</td>
	</tr>
</table>		
</div>

<div id="tab3" class="tab_content"> 	
<div id="divmodel" class="list_container"><p style="font-size:18px;font-weight:bold;color:gray">请稍候，正在重新载入图片...</p></div>
</div>

</div> 
</div>
 <form action="/doTradeReg.do" method="post" name="DXform">
     <input type="hidden" name ="pkid_path" id="pkid_path" value="">
     <input type="hidden" name ="bpm_id" value="2369">
	 <input type="hidden" name ="tabShow" value="1">
	  
 </form>
 
	
</body>
</html>
<script> 
if(<%=listsize%> > 4)
{
	var speed=30 
	demo2.innerHTML=demo1.innerHTML;
	function Marquee(){ 
		if(demo2.offsetTop-demo.scrollTop<=0) 
			demo.scrollTop-=demo1.offsetHeight 
		else{ 
			demo.scrollTop++;
		}
	}
	var MyMar=setInterval(Marquee,speed) 
	demo.onmouseover=function() {clearInterval(MyMar)} 
	demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)} 
}
</script> 
<script>
setProvince();
setOneClass(12);
</script> 